Skip to content

check: delete corrupt packs where nothing authenticates if other objects authenticate, fixes #10479 - #10643

Open
akasakariko wants to merge 1 commit into
borgbackup:masterfrom
akasakariko:check-repair-delete-empty-corrupt-pack-10479
Open

akasakariko wants to merge 1 commit into
borgbackup:masterfrom
akasakariko:check-repair-delete-empty-corrupt-pack-10479

Conversation

@akasakariko

Copy link
Copy Markdown

Description

Fixes #10479
Refs #10026

Previously, when no object in a corrupt pack authenticated during borg check --repair, Repository.salvage_pack returned SALVAGE_NOTHING_AUTHENTICATES before doing the second store.load() and left the pack in place, causing subsequent borg check and borg compact runs to keep failing unless borg check --repair --verify-data was run

This changes pack salvage to treat a corrupt pack in which no object authenticates like a zero-kept-objects salvage (deleting the pack and removing its chunk index entries, reported as a lossy salvage) only when both conditions hold:

  • a second store.load() returns the same bytes (checked before deciding on SALVAGE_NOTHING_AUTHENTICATES, so differing reads return SALVAGE_READS_DIFFER)
  • at least one other object in the repository passed validate and authenticate in the same run (either from another salvaged pack, from probing intact packs via Repository._authenticate_any_object, or from a pack that re-read intact), deferring empty corrupt packs if needed so the outcome does not depend on pack order while still leaving packs untouched on a broken validator/authenticator, wrong key, or single-pack repository

Docs and command help texts (check, compact, repo-compress, docs/internals/packs.rst, docs/faq.rst) and tests in src/borg/testsuite/repository_test.py and src/borg/testsuite/archiver/check_cmd_test.py are updated accordingly

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

…cts authenticate, fixes borgbackup#10479

When no object in a corrupt pack authenticates during borg check --repair, Repository.salvage_pack previously left the pack in place before performing the second store load, leaving borg check and borg compact failing on single-object packs such as damaged archive metadata packs

Changes:
- Always perform the second store.load() in Repository.salvage_pack before checking whether any object authenticated, so differing reads return SALVAGE_READS_DIFFER even when zero objects authenticate
- Add delete_if_empty (bool or callable, default False) to Repository.salvage_pack so a pack with zero authenticating objects is deleted (with new_pack_id=None, before_old_pack_delete called, and its index entries removed) when allowed
- In Repository._salvage_corrupt_packs, allow deleting such packs only once another object has passed validate and authenticate in the same run (from another salvaged pack, an intact pack probed via _authenticate_any_object, or a pack that re-read intact), deferring empty-salvage packs when no intact pack exists so the result is independent of pack order while preserving the guard against a broken authenticator or wrong key
- Update help texts, docs, and tests

Fixes borgbackup#10479
Refs borgbackup#10026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check --repair: a corrupt pack in which no object authenticates is never removed, check and compact keep failing

1 participant